//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	ISecurityService.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System;
using System.Collections.Generic;

namespace Smart.Common.Security
{
	/// <summary>
	/// Security service
	/// </summary>
	public interface ISecurityService
	{
		/// <summary>
		/// Security context
		/// </summary>
		SecurityContext Ctx { get; set; }

		/// <summary>
		/// Security source (lazy)
		/// </summary>
		SecurableSource Source { get; set; }

		/// <summary>
		/// Security concept (lazy)
		/// </summary>
		SecurityConcept Concept { get; set; }

		/// <summary>
		/// Creates security context
		/// </summary>
		void InitContext(Guid siteId, string serviceName);

		/// <summary>
		/// Init service (also fills lazy properties)
		/// </summary>
		void InitService();

		/// <summary>
		/// Create securable source
		/// </summary>
		SecurableSource CreateSource();

		/// <summary>
		/// Create security concept
		/// </summary>
		SecurityConcept CreateConcept();

		/// <summary>
		/// Create new securable filter
		/// </summary>
		SecurableFilter CreateFilter();

		/// <summary>
		/// Get securable object types
		/// </summary>
		ICollection<SecurableType> GetSecurableTypes();

		/// <summary>
		/// Ensure all securable security assignments
		/// </summary>
		/// <returns>true, if security changed</returns>
		bool EnsureSecurity(IDictionary<string, object> values);

		/// <summary>
		/// Ensure filtered securable objects of specified type security assignments
		/// </summary>
		/// <returns>true, if security changed</returns>
		bool EnsureSecurity(SecurableType securableType, IDictionary<string, object> values);

		/// <summary>
		/// Ensure filtered securable objects of specified type security assignments
		/// </summary>
		/// <returns>true, if security changed</returns>
		bool EnsureSecurity(SecurableType securableType, SecurableFilter filter, IDictionary<string, object> values);

		/// <summary>
		/// Ensure specified securable security assignments
		/// </summary>
		/// <returns>true, if security changed</returns>
		bool EnsureSecurity(string instanceId, IDictionary<string, object> values);

		/// <summary>
		/// <para>Ensure specified securable security assignments.</para>
		/// <para>Warning! Should be called from security context and securable should be from security context (aka RunElevated for SharePoint)!</para>
		///  </summary>
		/// <returns>true, if security changed</returns>
		bool EnsureSecurity(SecurableType securableType, ISecurable securable, IDictionary<string, object> values);

		/// <summary>
		/// <para>Ensure specified securable security assignments.</para>
		/// <para>Warning! Should be called from security context and securable should be from security context (aka RunElevated for SharePoint)!</para>
		/// </summary>
		/// <returns>true, if security changed</returns>
		bool EnsureSecurity(SecuritySecurableAssignments securableAssignments, IDictionary<string, object> values);
	}
}